import { useTransaction } from '@sker/core'
import { useReqBody, useLogger } from '@sker/runtime';
import { z } from 'zod'

const schema = z.object({
    sql: z.string(),
    params: z.array(z.any())
})
export default async () => {
    const logger = useLogger('query.post')
    const body = schema.parse(useReqBody())
    logger.log('info', 'test logger')
    const result = await useTransaction((manager) => {
        return manager.query(body.sql, body.params)
    })
    return result;
}
